package com.objectcarpentry.kaylee.ui.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;

import com.objectcarpentry.kaylee.KayleeFactory;
import com.objectcarpentry.kaylee.KayleePlugin;
import com.objectcarpentry.kaylee.Library;
import com.objectcarpentry.kaylee.Playlist;

public class NewPlaylistHandler extends AbstractHandler {

	public static final String DEFAULT_PLAYLIST_NAME = "new playlist";
	
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		Playlist pl = KayleeFactory.eINSTANCE.createPlaylist();
		pl.setName("New Playlist");
		KayleePlugin plugin = KayleePlugin.getDefault();
		EditingDomain domain = plugin.getEditingDomain();
		Library owner = plugin.getLibrary();
		Command c = AddCommand.create(domain, owner, null, pl);
		domain.getCommandStack().execute(c);
		return null;
	}
	
}
